#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>

int main(){
  int i = 0;
  char bar[102] = {0};
  const char c1[2] = "|";
  const char c2[2] = "/";
  const char c3[5] = "—";
  const char c4[2] = "\\";
  const char* spin[4] = {c1, c2, c3, c4};
  while(i <= 100){
    printf("[%-100s][%d%%][%s]", bar, i, spin[i%4]);
    fflush(stdout);
    bar[i++] = '#';
    usleep(102400);
    printf("\r\0333"); 
  }
  printf("\n");
  return 0;
}
